package com.interesting.examsystem.common.config.handlerInterceptor;

import cn.hutool.core.date.DateUtil;
import com.baomidou.mybatisplus.core.handlers.MetaObjectHandler;
import org.apache.ibatis.reflection.MetaObject;
import org.springframework.stereotype.Component;

/**
 * @ClassName: SqlMetaObjectHandler
 * @Author: ZhengXinyi
 * @Description: 基于mybatis plus 的Sql拦截器
 * @Date: 2021/7/25 2:25
 * @Version: 1.0
 */
@Component
public class SqlMetaObjectHandler implements MetaObjectHandler {
    @Override
    public void insertFill(MetaObject metaObject) {
        this.setFieldValByName("createTime", DateUtil.date(), metaObject);
    }

    @Override
    public void updateFill(MetaObject metaObject) {
        this.setFieldValByName("updateTime", DateUtil.date(), metaObject);
    }
}
